# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=deepin-image-viewer
pkgver=5.9.13
pkgrel=2
pkgdesc='An image viewing tool with fashion interface and smooth performance'
arch=('loong64' 'x86_64')
url="https://github.com/linuxdeepin/deepin-image-viewer"
license=('GPL3')
depends=('deepin-qt5integration' 'qt5-base' 'dtkcore' 'dtkgui' 'dtkwidget' 'deepin-image-editor'
         'gcc-libs' 'libraw')
makedepends=('cmake' 'ninja' 'qt5-tools')
optdepends=('deepin-manual: for help manual'
            'deepin-shortcut-viewer: for shortcut display')
groups=('deepin')
source=("https://github.com/linuxdeepin/deepin-image-viewer/archive/$pkgver/$pkgname-$pkgver.tar.gz"
        libraw-0.21.patch
        qt-5.15.11.patch)
sha512sums=('a6112c1dba0b20ff762933a0606798a95ba8121758adcc803b86bf418f486a13f3a584ee267c4d0709997e8b60b191187b76a9b6983af7828cfb7e9c6aceaf0a'
            '37587172bb74d6e243ae34120f6d0f27c5aa0ce46fc3faf53878c2827811ba922370820c62715f406bbfe9ebf14dbfc0042b85dc0ee7c51c3a4da08d840b7fd4'
            '80eed1be01595f7828ab05a8fe1aca68d5ca91fef01c299f0ccbbf0398a4ecbdeee5a2fefbc3d5219a0a0bd6e4e3e1a204339b1e7ea5f652cfb91291f351786c')

prepare() {
  cd deepin-image-viewer-$pkgver
  sed -i -e 's|qt5/plugins|qt/plugins|' -e 's|${Qt5Core_DIR}|/usr/lib/cmake/Qt5Core|' qimage-plugins/libraw/CMakeLists.txt
  patch -p1 < ../libraw-0.21.patch # Fix build with libraw 0.21
  patch -p1 < ../qt-5.15.11.patch # Fix build with Qt 5.15.11
}

build() {
  cd deepin-image-viewer-$pkgver
  cmake . -GNinja -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBDIR=lib
  ninja
}

package() {
  cd deepin-image-viewer-$pkgver
  DESTDIR="$pkgdir" ninja install
}
